package com.chain.BrotherExchange.viewmodel;

import android.text.TextUtils;

import com.chain.BrotherExchange.App;
import com.chain.BrotherExchange.R;
import com.chain.BrotherExchange.utils.Androids;

/**
 * 验证管理
 */
public class VerificationManage {

    /**
     * 提币
     */
    public static boolean verifyExtractCoinNumber(String number) {
        if (TextUtils.isEmpty(number)) {
            Androids.makeText(R.string.message_please_enter_number_coins);
            return false;
        }

        return true;
    }

    /**
     * 资产划转
     */
    public static boolean verifyTransferNumber(String number) {
        if (TextUtils.isEmpty(number)) {
            Androids.makeText(R.string.message_please_enter_number_transfers);
            return false;
        }
        return true;
    }

    /**
     * 提币类型
     */
    public static boolean verifyExtractCoinType(int type) {
        if (type == -1) {
            Androids.makeText(R.string.message_please_select_type_coin);
            return false;
        }
        return true;
    }

    /**
     * 提币地址
     */
    public static boolean verifyAddress(String address) {
        if (TextUtils.isEmpty(address)) {
            Androids.makeText(R.string.message_please_select_coin_address);
            return false;
        }
        return true;
    }

    /**
     * 备注
     */
    public static boolean verifyRemark(String remark) {
        if (TextUtils.isEmpty(remark)) {
            Androids.makeText(R.string.message_please_fill_remark);
            return false;
        }

        return true;
    }

    /**
     * 实名认证
     */
    public static boolean verifyRealNameAuthentication(String name, String id) {
        if (TextUtils.isEmpty(name)) {
            Androids.makeText(R.string.message_please_enter_real_name);
            return false;
        }

        if (TextUtils.isEmpty(id)) {
            Androids.makeText(R.string.message_please_enter_identification_number);
            return false;
        }

        return true;
    }

    /**
     * 检验用户昵称
     */
    public static boolean verifyNickname(String nickname) {
        if (TextUtils.isEmpty(nickname)) {
            Androids.makeText(R.string.message_please_enter_user_nickname);
            return false;
        }

        return true;
    }

    /**
     * 检验手机号码和密码
     */
    public static boolean verifyPasswordAndMobile(String mobile, String password) {
        return verifyMobilePhoneNumber(mobile) && verifyPassword(password);
    }

    /**
     * 检验短信验证码
     */
    public static boolean verifyMessageVerifyCode(String code) {
        if (TextUtils.isEmpty(code)) {
            Androids.makeText(R.string.message_please_enter_check_code);
            return false;
        }

        return true;
    }

    /**
     * 检验新密码
     */
    public static boolean verifyNewPassword(String password) {
        if (TextUtils.isEmpty(password)) {
            Androids.makeText("请输入新密码");
            return false;
        }
        return true;
    }

    /**
     * 检验确认密码
     */
    public static boolean verifyConfirmPassword(String confirmPassword) {
        if (TextUtils.isEmpty(confirmPassword)) {
            Androids.makeText(R.string.message_please_enter_confirmation_password);
            return false;
        }

        return true;
    }

    /**
     * 检验密码是否相同
     */
    public static boolean verifyPasswordSame(String password, String confirmPassword) {
        if (verifyPassword(password) && verifyConfirmPassword(confirmPassword)) {
            if (password.equals(confirmPassword)) {
                return true;
            } else {
                Androids.makeText(R.string.message_password_different_again);
            }
        }

        return false;
    }

    /**
     * 检验密码
     */
    public static boolean verifyPassword(String password) {
        if (TextUtils.isEmpty(password)) {
            Androids.makeText(R.string.message_please_enter_your_password);
            return false;
        }

        if (password.length() < 6 || password.length() > 12){
            Androids.makeText(R.string.message_recommended_password_length);
            return false;
        }

        return true;
    }

    /**
     * 检验手机号码
     */
    public static boolean verifyMobilePhoneNumber(String phoneNumber) {
        if (TextUtils.isEmpty(phoneNumber)) {
            Androids.makeText(R.string.message_please_enter_phone_number);
            return false;
        }

//        if (phoneNumber.length() < 11) {
//            Androids.makeText("请输入正确的手机码");
//            return false;
//        }

        return true;
    }


    public static boolean verifyTransferPassword(String password) {
        if (TextUtils.isEmpty(password)) {
            Androids.makeText(R.string.message_please_enter_transaction_password);
            return false;
        }

        if (password.length() < 6 || password.length() > 12){
            Androids.makeText(R.string.message_recommended_password_length);
            return false;
        }

        return true;
    }

    public static boolean verifyInviteCode(String inviteCode) {
        if (TextUtils.isEmpty(inviteCode)) {
            Androids.makeText("请输入邀请码");
            return false;
        }

        return true;
    }
}
